<template>
  <div>
    <promoter v-if="nodeConfig.type==0" v-model="nodeConfig"></promoter>

    <approver v-if="nodeConfig.type==1" v-model="nodeConfig"></approver>

    <send v-if="nodeConfig.type==2" v-model="nodeConfig"></send>

    <branch v-if="nodeConfig.type==4" v-model="nodeConfig">
      <template v-slot="slot">
        <node-wrap v-if="slot.node" v-model="slot.node.childNode"></node-wrap>
      </template>
    </branch>

    <node-wrap v-if="nodeConfig.childNode" v-model="nodeConfig.childNode"></node-wrap>
  </div>
</template>

<script>
	import approver from './nodes/approver.vue'
	import promoter from './nodes/promoter.vue'
	import branch from './nodes/branch.vue'
	import send from './nodes/send.vue'

	export default {
		props: {
			value: { type: Object, default: () => {} }
		},
    name: "nodeWrap",
		components: {
			approver,
			promoter,
			branch,
			send
		},
		data() {
			return {
				nodeConfig: {},
			}
		},
		watch:{
			value(val){
				this.nodeConfig = val
			},
			nodeConfig(val){
				this.$emit("input", val)
			}
		},
		mounted() {
			this.nodeConfig = this.value
		},
		methods: {

		}
	}
</script>

<style>
</style>
